package com.juicygames.framework.gamepart;

import com.juicygames.framework.GameAction;

public class ActionForwarder extends GameHandler {
	
	private GamePart target;
	
	public ActionForwarder(GamePart self, GamePart target, Class<? extends GameAction> actionToForward) {
		super(self);
		setActionClassHandled(actionToForward);
		this.target = target;
	}
	
	public void handle(GameAction action) {
		target.handleAction(action);
	}
	
	public boolean equals(Object other) {
		if (!(other instanceof ActionForwarder)) {
			return false;
		}
		ActionForwarder f = (ActionForwarder) other;
		boolean targetsEqual = target == f.target;
		boolean selvesEqual = self == f.self;
		boolean actionsEqual = getActionClassHandled() == f.getActionClassHandled();
		return targetsEqual && selvesEqual && actionsEqual;
	}

}
